// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: FZ Intro Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 75 : TYPE_FZINTRO


// Static Values

// Tables

event ObjectMain
	switch object.state
	case 0
		tileLayer[2].scrollPos = 0x800000
		hParallax[0].scrollPos = -0x800000
		if recAnimation != 0
			temp0 = recAnimation
			currentPlayer = 0
			while currentPlayer < playerCount
				object[currentPlayer].xpos = object.xpos
				object[currentPlayer].ypos = object.ypos
				CreateTempObject(TypeName[FZ Intro], 0, object.xpos, object.ypos)
				object[tempObjectPos].state = 1
				object[tempObjectPos].value0 = currentPlayer
				object[tempObjectPos].direction = temp0
				object[tempObjectPos].direction &= 255
				temp0 >>= 8
				object[tempObjectPos].animation = temp0
				object[tempObjectPos].animation &= 255
				temp0 >>= 8
				object[currentPlayer].yvel = -0x80000
				object[currentPlayer].gravity = GRAVITY_AIR
				object[currentPlayer].state = PlayerObject_HandleAir
				currentPlayer++
			loop
			recAnimation = 0
		end if
		object.type = TypeName[Blank Object]
		temp0 = stage.newYBoundary2
		temp0 -= screen.ysize
		stage.newYBoundary1 = temp0
		break
	case 1
		currentPlayer = object.value0
		object[currentPlayer].direction = object.direction
		object[currentPlayer].animation = object.animation
		if object[currentPlayer].animation == ANI_JUMPING
			object[currentPlayer].state = PlayerObject_HandleAir
			object.state = 2
		end if
		if object[currentPlayer].animation == ANI_FLYING
			object[currentPlayer].state = PlayerObject_HandleTailsFlight
			object[currentPlayer].value26 = 0x800
			object[currentPlayer].yvel >>= 2
			object.state = 2
		end if
		if object[currentPlayer].animation == ANI_GLIDING
			if object[currentPlayer].direction == FLIP_X
				object[currentPlayer].state = PlayerObject_KnuxGlideLeft
			else
				object[currentPlayer].state = PlayerObject_KnuxGlideRight
			end if
			object.state = 2
		end if
		if object[currentPlayer].animation == ANI_GLIDING_DROP
			object[currentPlayer].state = PlayerObject_KnuxGlideDrop
			object.state = 2
		end if
		if object.state != 2
			object[currentPlayer].state = PlayerObject_HandleAir
			object[currentPlayer].direction = FLIP_NONE
			object[currentPlayer].animation = ANI_BOUNCING
			object.state = 2
		end if
		break
	case 2
		object.type = TypeName[Blank Object]
		break
	end switch
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
